import sys
file = open("input.txt")
data = file.readlines()
N = int(data[0])
x1 = [-1] * (N + 1)
x2 = [-1] * (N + 1)
y1 = [-1] * (N + 1)
y2 = [-1] * (N + 1)
for i in range(1, N + 1):
    x1[i], y1[i], x2[i], y2[i] = map(int, data[i].split())
def flashmob(N, x1, y1, x2, y2):
    X1 = max(x1)
    X2 = max(x2)
    X = max(X1, X2)
    Y1 = max(y1)
    Y2 = max(y2)
    Y = max(Y1, Y2)
    box = [[0] * (X + 1) for i in range(Y + 1)]
    for i in range(N, 0, -1):
        if x1[i] == x2[i]:
            if y1[i] <= y2[i]:
                while y1[i] <= y2[i]:
                    box[y1[i]][x1[i]] = i
                    y1[i] += 1
            else:
                while y1[i] >= y2[i]:
                    box[y1[i]][x1[i]] = i
                    y1[i] -= 1
        elif y1[i] == y2[i]:
            if x1[i] <= x2[i]:
                while x1[i] <= x2[i]:
                    box[y1[i]][x1[i]] = i
                    x1[i] += 1
            else:
                while x1[i] >= x2[i]:
                    box[y1[i]][x1[i]] = i
                    x1[i] -= 1
    visited = set([0])
    ans = []
    for i in range(1, len(box)):
        for j in range(1, len(box[0])):
            if box[i][j] not in visited:
                ans += [(j, i)]
                visited.add(box[i][j])
    if len(visited) < N + 1:
        return (0, [])
    else:
        return (N, ans)
tab = flashmob(N, x1, y1, x2, y2)
print(tab[0])
if tab[0] != 0:
    for i in range(len(tab[1])):
        print(tab[1][i][0], tab[1][i][1])